


//
//  VistorView.swift
//  SinaProject
//
//  Created by guochong on 16/4/20.
//  Copyright © 2016年 吴学宇. All rights reserved.
//

import UIKit

protocol VistorViewDelegate : NSObjectProtocol{
    func loginBtnDidClicked ();
    func registerDidClicked();
}

class VistorView: UIView {

    
   weak var delegate : VistorViewDelegate?;
    

   override init(frame: CGRect) {
        
    super.init(frame: frame);
    
      self.addSubview(iconView)
 self.addSubview(maskfillView)
       self.addSubview(homeIcon)
    
    self.addSubview(messageLabel)
     self.addSubview(loginButton)
       self.addSubview(registerButton);
  
    
    iconView.xmg_AlignInner(type: XMG_AlignType.Center, referView: self, size:nil);
    
    homeIcon.xmg_AlignInner(type: XMG_AlignType.Center, referView: self, size: nil);
    
    messageLabel.xmg_AlignVertical(type: XMG_AlignType.BottomCenter, referView: iconView, size: nil, offset: CGPointMake(0, 10));
    
    let layoutContract = NSLayoutConstraint(item: messageLabel, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: 224);
    
    addConstraint(layoutContract);
    
    loginButton.xmg_AlignVertical(type: XMG_AlignType.BottomLeft, referView: messageLabel, size: CGSizeMake(100, 30), offset: CGPointMake(0, 10));
    registerButton.xmg_AlignVertical(type:XMG_AlignType.BottomRight, referView: messageLabel, size: CGSizeMake(100, 30), offset: CGPointMake(0,10))
    
    
    maskfillView.xmg_Fill(self)
    
    }
    
    
    

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
   
    
    
    // MARK -  懒加载控件
    /// 转盘
    private lazy var iconView: UIImageView = {
        let iv = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
        iv.sizeToFit();
        return iv
    }()
    /// 图标
    private lazy var homeIcon: UIImageView = {
        let iv = UIImageView(image: UIImage(named: "visitordiscover_feed_image_house"))
        return iv
    }()
    /// 文本
    private lazy var messageLabel: UILabel = {
        let label = UILabel()
        label.numberOfLines = 0
        label.textAlignment = NSTextAlignment.Center
        label.textColor = UIColor.darkGrayColor()
        label.text = "打附加赛可垃圾分类考试的减肥机的两款手机立刻"
        return label
    }()
    /// 登录按钮
    private lazy var loginButton: UIButton = {
        let btn = UIButton()
        btn.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        btn.setTitle("登录", forState: UIControlState.Normal)
        btn.setBackgroundImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Normal)
        
        btn.addTarget(self, action: #selector(VistorView.loginDidClicked), forControlEvents: UIControlEvents.TouchUpInside)
        
   
        
        return btn
    }()
    /// 注册按钮
    private lazy var registerButton: UIButton = {
        let btn = UIButton()
        btn.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
        btn.setTitle("注册", forState: UIControlState.Normal)
        
        btn.setBackgroundImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Normal)
        
        btn.addTarget(self, action: #selector(VistorView.registerDidClicked), forControlEvents: UIControlEvents.TouchUpInside)
       
        return btn
    }()
    
    private lazy var maskfillView : UIImageView = {

        let maskfillView = UIImageView(image: UIImage(named: "visitordiscover_feed_mask_smallicon"));
        
        return maskfillView;
    
        
    }()
    
    func registerDidClicked(){
        
        
    }
    
    
     func loginDidClicked(){
        
        
        
    }
    

}
